home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_04 / 9n04084a < prev    next >
Text File  |  1991-02-17  |  944b  |  40 lines

  1. /********************************************************************/
  2. /*            Formatted output functions.    Note: the return value     */
  3. /*          is only good until a form function is used again.         */
  4. /********************************************************************/
  5.             
  6. #ifndef INCLUDE_form
  7. #define INCLUDE_form
  8.  
  9. #ifndef __STDIO_H
  10.     #include <stdio.h>
  11. #endif
  12.  
  13. static char _form_s[256];
  14.  
  15.  
  16. static char *dec(long i,int w=0)
  17.         { sprintf(_form_s, "%*ld", w, i);
  18.           return _form_s;
  19.         }
  20.  
  21. static char *hex(int i,int w=0)
  22.         { sprintf(_form_s, "%0*X", (w ? w : sizeof(int)), i);
  23.           return _form_s;
  24.         }
  25.  
  26. static char *hex(long i, int w=0)
  27.         { sprintf(_form_s, "%0*X", (w ? w : sizeof(long)), i);
  28.           return _form_s;
  29.         }
  30. static char *chr(int i,int w=0)
  31.         { sprintf(_form_s, "%*c", w, i);
  32.           return _form_s;
  33.         }
  34.  
  35. static char *form(char *f,...)
  36.         { vsprintf(_form_s, f, ...); return _form_s; }
  37.  
  38. #endif
  39.  
  40.